/*[1,2,3,4,5,6,7,8,9,0]=>"(123) 456-7890" */
const array=[1,2,3,4,5,6,7,8,9,0]

function creatPhoneNumber(array) {
    return `(${array[0]}${array[1]}${array[2]}) ${array[4]}${array[5]}${array[6]}-${array[7]}${array[8]}${array[9]}${array[0]}`
    
}
console.log(creatPhoneNumber(array));console.log();

function creatPhoneNumber2(array) {
    array=array.join("")
   
    /* console.log(array.substring(0,3));
    console.log(array.substring(3,6));
    console.log(array.substring(6,10)); */
    return `(${array.substring(0,3)}) ${array.substring(3,6)}-${array.substring(6,10)}`

}
console.log(creatPhoneNumber2(array));console.log();

function creatPhoneNumber3(array) {
    format="(xxx) xxx-xxxx"
    for (let index = 0; index < array.length; index++) {
        format=format.replace('x',array[index])
        
    }
    
    return format
}
console.log(creatPhoneNumber3(array));console.log();


